import * as VueRouter  from "vue-router";
import Layout from "@/components/Layout/index.vue";
import {CustomRouteRecordRaw} from "./type"
export const menuList:CustomRouteRecordRaw[] = [
  {
    path: "",
    name: "reward",
    meta: {
      linkName: "收益数据",
      iconName: "",
    },
    component: () =>
      import(/* webpackChunkName: "reward" */ "@/views/reward/index.vue"),
  },
  {
    path: "modifyPassword",
    name: "modifyPassword",
    meta: {
      linkName: "修改密码",
      iconName: "",
    },
    component: () =>
      import(/* webpackChunkName: "ModifyPassword" */ "@/views/modify-password/index.vue")
  },
];
const handleRouter = (routerList:CustomRouteRecordRaw[], baseUrl = "/") => {
  routerList.forEach((router) => {
    router.path =
      baseUrl != "/" ? baseUrl + "/" + router.path : baseUrl + router.path;
    if (router.children) {
      handleRouter(router.children, router.path);
    }
  });
};
//处理menuList
handleRouter(menuList);
const routes:CustomRouteRecordRaw[] = [
  {
    path: "/",
    name: "layout",
    component: Layout,
    children:menuList
  },
  {
    path: "/login",
    name: "Login",
    component: () =>
      import(/* webpackChunkName: "login" */ "@/views/login/index.vue"),
  },
];

const router = VueRouter.createRouter({
  history: VueRouter.createWebHashHistory(),
  routes:routes as VueRouter.RouteRecordRaw[], 
});
export default router;
